package com.lagou.edu.dao;

import com.lagou.edu.pojo.AuthCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author stevejson
 */
public interface CodeDao extends JpaRepository<AuthCode, Long>{
    /**
     * 查询最新的一个code
     * @param email email
     * @param code code
     * @return authcode
     */
    @Query(value = "select * from lagou_auth_code where email=:email and code=:code  order by createtime desc limit 1", nativeQuery = true)
    public AuthCode findLastCode(@Param(value = "email") String email, @Param(value = "code") String code);
}
